package com.example;  // 这里要改成 com.example

import com.example.entity.Product;
import com.example.entity.Student;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainApp {
    public static void main(String[] args) {
        // 1. 加载Spring配置文件，初始化IoC容器
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

        // 2. 从容器中获取Bean
        Product product = (Product) context.getBean("product");
        Student student = (Student) context.getBean("student");

        // 3. 输出Bean内容
        System.out.println("=== Product Bean ===");
        System.out.println(product);
        System.out.println("\n=== Student Bean ===");
        System.out.println(student);

        // 4. 关闭容器
        ((ClassPathXmlApplicationContext) context).close();
    }
}